/*
 * acm2136.c
 *
 *  Created on: 7 Apr 2010
 *      Author: xuxu
 */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int count,n;
	int num[1001];
	int mark[1001];
	int i,j;
	int bo;
	scanf("%d",&count);
	while(count--)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&num[i]);
		}
		memset(mark,0,sizeof(mark));
		mark[0]=1;
		for(i=1;i<n;i++)
		{
			bo=-1;
			for(j=0;j<=i;j++)
			{
				if(num[j]<num[i]&&mark[j]>bo)
					bo=mark[j];
			}
			if(-1==bo)
				mark[i]=1;
			else
				mark[i]=bo+1;
		}
		bo=0;
		for(i=0;i<n;i++)
		{
			if(bo<mark[i])
				bo=mark[i];
		}
		printf("%d\n",bo);
		if(count)
			printf("\n");
	}
	return 0;
}
